#ifndef KERNEL_H_
#define KERNEL_H_

#include "cpudef.h"

#ifndef F_CPU
  #error "CPU Frequency error"
#endif

struct CPUState {
  BYTE sreg;
  unsigned Carry_Flag : 1;
  unsigned Zero_Flag : 1;
  unsigned Negative_Flag : 1;
  unsigned V : 1;
  unsigned S : 1;
  unsigned H : 1;
  unsigned T : 1;
  unsigned I : 1;
}CPUState;

#define EI __asm__ __volatile__ ("sei");
#define DI __asm__ __volatile__ ("cli");
#define RETI __asm__ __volatile__ ("reti");

#define IRQ(vector) 											\
  void vector(void) __attribute__ ((signal));	\
  void vector(void)

#define __PORTB (BYTE *)0x38

#define mov(b, a) \
	(* b) = a;


#define bit(b) \
  1 << b;

#define XM_RUN 1
#define XM_QUIT 0
#define XM_STOP 2

#define QUIT postMessage(XM_QUIT)

extern void initialize();
extern void terminate();
extern void run();

int main(void);

#endif /* KERNEL_H_ */
